<template>
	<view v-if="!bol" class="content" :style="{'height':height+'px'}">
		<view class="msg-content">
			<image src="../static/MsgClose.png" class="msg-close" @click="close"></image>
			<image src="../static/MsgTitle.png" class="msg-title"></image>
			<image src="../static/MsgWelcome.png" class="welcome"></image>
			<button  class="msg-btn" open-type="getUserInfo" @getuserinfo="getuserinfo" withCredentials="true"></button>
		</view>
	</view>
</template>

<script>
	import url from './hosturl.js';
	export default {
		name:"msg",
		data() {
			return {
				bol:false,
				height: uni.getSystemInfoSync().screenHeight+50
			};
		},
		methods:{
			close(){
				this.bol=true;
				uni.showTabBar();
			},
			getuserinfo(){
				var that=this;
				//获取用户信息
				uni.getUserInfo({
					provider:'weixin',
					success(res) {
						uni.setStorageSync('avatarUrl',res.userInfo.avatarUrl);
						uni.setStorageSync('nickName',res.userInfo.nickName);
						uni.request({
							url:url+'/Main/InLogin',
							method:'post',
							data:{
								Fcode:'',
								code:uni.getStorageSync('code'),
								rawData:res.rawData
							},
							header: {
							        "Content-Type": "application/x-www-form-urlencoded"
							},
							success(res) {
								// uni.setStorageSync('token',res.data.token);
								// uni.setStorageSync('openid',res.data.openid);
								// uni.setStorageSync('session_key',res.data.session_key);
								uni.setStorageSync('token','fee821e5-377a-4bdd-854f-c3cccd33d7b8');
								uni.setStorageSync('openid','o3Axb5OPtjZNAAdDrNSYN3RwS7fk');
								uni.setStorageSync('session_key','lt8KcIF7oU+ztnU9P41E7g==');
								uni.setStorageSync('login',true);
								that.bol=true;
								uni.showTabBar();
								
							}
						})
					}
				});
			}	
		},
		mounted() {
			uni.hideTabBar();
			if(uni.getStorageSync('login')){
				this.bol=true;
				uni.showTabBar();
			}
		}
	}
</script>

<style>
.content{width: 100%;height: 100%;background: rgba(0,0,0,0.5);position: fixed;top: 0;left: 0;z-index: 10000; }
.msg-content{width: 450rpx;height: 530rpx;background: #e8cbf4;margin: 160rpx auto;border-radius:20rpx ;padding: 20rpx;}
.msg-close{width: 40rpx;height: 40rpx;float: right;display: inline-block;}
.msg-title{height: 315rpx;width: 345rpx;margin-left: 40rpx;margin-top: -30rpx;display: inline-block;}
.welcome{height: 50rpx;width: 220rpx;margin-left: 110rpx;margin-top: 25rpx;}
.msg-btn{width: 180rpx;height: 40rpx;margin-left: 125rpx;margin-top: 20rpx;background:url('../static/MsgBtn.png') no-repeat 0 0;background-size:100% 100%; }
.none{display: none;}
</style>
